package com.mytools;

import javax.swing.*;

import org.jsoup.Jsoup;
import org.jsoup.internal.StringUtil;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.google.gson.Gson;
import com.mytools.util.DownloadUtils;
import com.mytools.util.ImgMatchUtil;
import com.mytools.util.MyHttpsUtils;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;

public class MyDowload {
	public static Gson gson = new Gson();
	private static final ConcurrentHashMap<String, Object> cahceMap=new ConcurrentHashMap<String, Object>();
	public static volatile boolean Runing = false;
	public static Map<String,String> cookie2=new HashMap<>();
	
	public static void main(String[] args) throws Exception {
		final JFrame jf = new JFrame("曦曦工具窗口");
		jf.setSize(700, 500);
		jf.setLocationRelativeTo(null);
		jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		jf.setLayout(new BorderLayout());
		
		
		boolean isDownload=true;
		
		// 创建一个 5 行 10 列的文本区域
		final JTextArea textArea = new JTextArea(20, 50);
		// 设置自动换行
		textArea.setLineWrap(true);
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(28, 209, 752, 265);
		scrollPane_1.setViewportView(textArea);
		jf.add(scrollPane_1, BorderLayout.CENTER);

		final JTextArea textArea2 = new JTextArea(10, 20);
		// 设置自动换行
		textArea2.setLineWrap(true);
		textArea2.setEditable(false);
		JScrollPane scrollPane_2 = new JScrollPane();
		scrollPane_2.setBounds(100, 100, 100, 100);
		scrollPane_2.setViewportView(textArea2);
		jf.add(scrollPane_2, BorderLayout.EAST);

		
		JPanel panel = new JPanel();
		JCheckBox checkzt下载主图=new JCheckBox("下载主图");
		JCheckBox checkxqt下载详情图=new JCheckBox("下载详情图");
		JCheckBox checkxqjstu下载详情介绍图=new JCheckBox("下载详情介绍图");
		panel.add(checkzt下载主图);
		panel.add(checkxqt下载详情图);
		panel.add(checkxqjstu下载详情介绍图);
		
		
		final Label tepLabel = new Label("==============");
		panel.add(tepLabel);
		// 创建一个提交按钮，点击按钮获取输入文本
		JButton btn = new JButton("开始下载");
		panel.add(btn);
		jf.add(panel, BorderLayout.NORTH);
		//////
		JPanel panelboot = new JPanel();

		
		final Label cookieLabel = new Label("cookie");
		panelboot.add(cookieLabel);
		final JTextField cookieField = new JTextField("", 10);
		cookieField.setFont(new Font(null, Font.PLAIN, 15));
		panelboot.add(cookieField);

		final JTextField pathField = new JTextField("D:\\File", 10);
		pathField.setFont(new Font(null, Font.PLAIN, 15));
		panelboot.add(pathField);

		JButton btn2 = new JButton("选择图片存储路径");
		btn2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				showFileSaveDialog(jf, pathField);
			}
		});
		panelboot.add(btn2);
		jf.add(panelboot, BorderLayout.SOUTH);

		btn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (textArea.getText() == null || "".equals(textArea.getText().trim())) {
					JOptionPane.showMessageDialog(jf, "请先输入要下载页面的源码", "错误", JOptionPane.WARNING_MESSAGE);
					return;
				}
				if (!Runing) {
					synchronized (gson) {
						if (Runing) {
							return;
						} else {
							Runing = true;
						}
					}
					new Thread(() -> {
					  cahceMap.put("checkzt", checkzt下载主图.isSelected());
					  cahceMap.put("checkxqt", checkxqt下载详情图.isSelected());
					  cahceMap.put("checkxqjstu", checkxqjstu下载详情介绍图.isSelected());
					  download(textArea.getText(), pathField.getText(), textArea2, jf, cookieField.getText());
						
						
					}).start();
				} else {
					JOptionPane.showMessageDialog(jf, "上个任务还在执行中！请稍后", "错误", JOptionPane.WARNING_MESSAGE);
					return;
				}

			}
		});

		jf.setVisible(true);
	}

	private static String showFileSaveDialog(Component parent, JTextField msgTextArea) {
		// 创建一个默认的文件选取器
		JFileChooser fileChooser = new JFileChooser();

		// 设置打开文件选择框后默认输入的文件名
//        fileChooser.setSelectedFile(new File("测试文件.zip"));

		fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

		// 打开文件选择框（线程将被阻塞, 直到选择框被关闭）
		int result = fileChooser.showSaveDialog(parent);

		if (result == JFileChooser.APPROVE_OPTION) {
			// 如果点击了"保存", 则获取选择的保存路径
			File file = fileChooser.getSelectedFile();
			msgTextArea.setText(file.getAbsolutePath());
			return file.getAbsolutePath();
		}
		return "";
	}

	private static synchronized void download(String html, String path, JTextArea textArea, JFrame jf, String cookie
			) {
		try {
			StringBuilder sb = new StringBuilder();
			int count = 0;
			if (path == null || "".equals(path)) {
				path = "D:\\File";
			}
			path = path + "\\" + dateFormat(new Date()) + "\\";
			Document doc = Jsoup.parse(html);
			sb.append("店名").append(",").append("类型").append(",").append("价格").append(",").append("销量(该店所有类型总成交数)")
					.append(",").append("评价数").append(",").append("图片").append(",").append("图片在线预览地址").append(",")
					.append("店铺地址").append(",").append("活动价格").append(",").append("活动类型").append(",").append("活动价格2")
					.append(",").append("活动类型2").append(",").append("店铺地址带商品").append(",")
					.append("店铺名").append(",")
					.append("型号").append(",")
					.append("填充物").append(",")
					.append("面料").append(",")
					.append("风格").append(",")
					.append("是否可拆洗").append(",")
					.append("附加功能").append(",")
					.append("是否带储物空间").append(",")
					.append("产地").append(",")
					.append("地市").append(",")
					.append("区县").append(",")
					.append("详情").append(",")
					.append("页面主推价格 ").append(",")
					.append("页面主推图片").append(",")
					.append("预售价格").append(",")
					.append("\n");
			boolean danpu = false;
			Elements items = null;
			Element J_ItemList = doc.getElementById("J_ItemList");
			if (J_ItemList == null || "".equals(J_ItemList.toString())) {
				items = doc.getElementsByClass("item");
				danpu = true;
			} else {
				items = J_ItemList.getElementsByClass("productTitle");
			}
			for(Element i : items){
				String url = "";
				if (!danpu) {
					url = i.selectFirst("a").attr("href");
					if (url.indexOf("&areaId") > -1) {
						url = "https:" + url.substring(0, url.indexOf("&areaId"));
					} else {
						url = "https:" + url.substring(0, url.indexOf("&user_id"));
					}

				} else {
					url = "https:" + i.selectFirst("a").attr("href");
				}
				Map<String, String> heads1 = new HashMap();
				heads1.put("Cookie", cookie);
				heads1.put("referer", "https://detail.tmall.com/");
				try {
					String data = MyHttpsUtils.requestGet(url,heads1);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			for (Element i : items) {
				String chengjiao = "";
				String pingjia = "";
				String dianpuming = "";
				String 页面主推价格 = "";
				String 页面主推图片 = "";
				try {
					try {
						if (danpu) {
							chengjiao = i.getElementsByClass("sale-num").get(0).ownText();
						} else {
							chengjiao = ((Element) i.parentNode()).getElementsByClass("productStatus").select("em").text();
							页面主推价格=((Element) i.parentNode()).getElementsByClass("productPrice").select("em")
							.attr("title");
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					try {
						if (danpu) {
							pingjia = i.getElementsByClass("title").get(0).selectFirst("span").ownText();
							pingjia = pingjia.substring(3);
						} else {
							pingjia = ((Element) i.parentNode()).getElementsByClass("productStatus").select("a").text();
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					try {
						页面主推图片=((Element) i.parentNode()).selectFirst("img").attr("src");
						if(StringUtil.isBlank(页面主推图片)) {
							页面主推图片=((Element) i.parentNode()).selectFirst("img").attr("data-ks-lazyload");
						}
						if(!StringUtil.isBlank(页面主推图片)) {
							页面主推图片="http:"+页面主推图片;
						}
					} catch (Exception e) {
						// TODO: handle exception
					}
					try {
						if (danpu) {
							dianpuming="";
						} else {
							dianpuming = ((Element) i.parentNode()).getElementsByClass("productShop-name").select("a").text();
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					String url = "";
					if (!danpu) {
						url = i.selectFirst("a").attr("href");
						if (url.indexOf("&areaId") > -1) {
							url = "https:" + url.substring(0, url.indexOf("&areaId"));
						} else {
							url = "https:" + url.substring(0, url.indexOf("&user_id"));
						}
						
					} else {
						url = "https:" + i.selectFirst("a").attr("href");
					}

					getShopDetail2(url, path, pingjia, chengjiao, count, sb, textArea, cookie, danpu,dianpuming,页面主推价格,页面主推图片);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			WriteCsvFile(path, sb);
			JOptionPane.showMessageDialog(jf, "下载完成", "提示", JOptionPane.WARNING_MESSAGE);

		} finally {
			Runing = false;
		}
	}

	public static String replceErrorPath(String path) {
		if (path == null) {
			return "";
		}
		path = path.trim();
		path = path.replace("\"", "-");
		path = path.replace("/", "-");
		path = path.replace(":", "-");
		path = path.replace("*", "x");
		path = path.replace("?", "-");
		path = path.replace("\\", "-");
		path = path.replace("<", "(");
		path = path.replace(">", ")");
		path = path.replace(">", ")");
		path = path.replace("|", "-");

		return path;
	}

	public static void WriteCsvFile(String path, StringBuilder sb) {
		try {
			File fout = new File(path + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".csv");
			 if (!fout.getParentFile().exists()&&!fout.isDirectory()){
				 fout.getParentFile().mkdirs();
	            } 
			FileOutputStream fos = new FileOutputStream(fout);
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
			bw.write(sb.toString());
			bw.newLine();
			bw.flush();
			bw.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public static void getShopDetail2(String url, String path, String pingjia, String chengjiao, int count,
			StringBuilder sb, JTextArea textArea, String cookie, boolean dianpu
			,String dianpuming,String 页面主推价格,String 页面主推图片) throws Exception {
		System.out.println("****店铺详情url:   " + url);
		Map<String, String> heads1 = new HashMap();
		heads1.put("Cookie", cookie);
		heads1.put("referer", "https://detail.tmall.com/");
		String data = MyHttpsUtils.requestGet(url,heads1);
		/// 价格
		Map skuMap = new HashMap(); // 商品价格列表
//		Map skuListMapskuId = new HashMap();
		Map skuListMap = new HashMap(); // 商品列表
		Map propertyPics = new HashMap(); // 商品图片
		String initApi = "";
		String titleString = "";
		try {
			List<String> list2 = ImgMatchUtil.getMatchList(data, "\\{\"valItemInfo.*", true);
			Map info = gson.fromJson(list2.get(0), Map.class);
			skuMap = (Map) ((Map) info.get("valItemInfo")).get("skuMap");
			List skuList = (List) ((Map) info.get("valItemInfo")).get("skuList");
			if (skuList != null) {
				for (Object o : skuList) {
					Map omap = (Map) o;
//					skuListMapskuId.put(omap.get("skuId"),omap);
					skuListMap.put(omap.get("pvs"), omap);
				}
			}
			propertyPics = (Map) info.get("propertyPics");
			initApi = (String) info.get("initApi");
			titleString = (String) ((Map) info.get("itemDO")).get("title");
			// 下载店铺主图
			if (propertyPics != null && propertyPics.size() > 0) {
				List<String> defaultPic = (List<String>) propertyPics.get("default");
				for (String defpicUrl : defaultPic) {
					String realpath = titleString + "&&主图&&" + defpicUrl.substring(defpicUrl.lastIndexOf("/") + 1);
					realpath = replceErrorPath(realpath);
					realpath = path + replceErrorPath(titleString) + "/" +"主图/"+ realpath;
					System.out.println("主图下载：" + realpath);
					if((boolean) cahceMap.get("checkzt")) {
						DownloadUtils.download("http:" + defpicUrl, realpath);
					}
					
				}
			}
			String descUrl = (String) ((Map) info.get("api")).get("descUrl");
			String descdata = MyHttpsUtils.get("https:" + descUrl, "GBK");
			List<String> descImglist = ImgMatchUtil.listImgSrc(descdata);
			for (String str : descImglist) {
				String realpath = titleString + "&&详情图&&" + str.substring(str.lastIndexOf("/") + 1);
				realpath = replceErrorPath(realpath);
				realpath = path + replceErrorPath(titleString) + "/"  +"详情图/"+  realpath;
				System.out.println("主图下载：" + realpath);
				if((boolean) cahceMap.get("checkxqjstu")) {
					DownloadUtils.download(str, realpath);
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
			textArea.append("〒▽〒获取valItemInfo异常,coookie已经过期，请滑方块后，重新获取cookie重试" + e.getMessage() + "\n");
		}
		Map priceInfo = new HashMap();
		try {
			if (initApi == null || "".equals(initApi)) {
				List<String> teplist = ImgMatchUtil.getMatchList(data,
						"//mdskip.taobao.com/core/initItemDetail.htm([^\"|^'])*", true);
				initApi = teplist.get(0);
			}
			if (cookie != null && !"".equals(cookie)) {
				Map<String, String> heads = new HashMap();
				heads.put("cookie", cookie);
				heads.put("referer", "https://detail.tmall.com/");
				System.out.println("initApi:" + MyHttpsUtils.urlEncode("https:" + initApi));
				String priceJson = MyHttpsUtils.get(MyHttpsUtils.urlEncode("https:" + initApi), "GBK", heads);
				System.out.println("priceJson:" + priceJson);
				List<String> priceJsonList = ImgMatchUtil.getMatchList(priceJson, "\\{.*\\}", true);
				priceJson = priceJsonList.get(0);
				Map info = gson.fromJson(priceJson, Map.class);
				Map defaultModel = (Map) info.get("defaultModel");
				Map itemPriceResultDO = (Map) defaultModel.get("itemPriceResultDO");
				priceInfo = (Map) itemPriceResultDO.get("priceInfo");
			}
		} catch (Exception e) {
			e.printStackTrace();
			textArea.append("获取活动价格异常" + e.getMessage() + "\n");
		}

		Document datadoc = Jsoup.parse(data);
		Elements titles = datadoc.getElementsByAttributeValue("data-spm", "1000983");

		try {
			if (titles != null && titles.size()>0 && "".equals(titleString)) {
				titleString = titles.get(0).ownText();
			}
		} catch (Exception e) {
			e.printStackTrace();
			textArea.append("获取店铺名异常\n");
		}

		//获取商品详细信息
		String 型号="";
		String 填充物="";
		String 商品属性="";
		String 面料="";
		String 风格="";
		String 是否可拆洗="";
		String 附加功能="";
		String 是否带储物空间="";
		String 产地="";
		String 地市="";
		String 区县="";
		try {
			Elements lis = datadoc.getElementById("J_AttrUL").children();
			if(lis !=null ) {
				for (Element li : lis) {
					if(li.text() !=null && li.text().contains("型号")) {
						型号=li.text().replace("型号:", "").trim();
					}
					if(li.text() !=null && li.text().contains("填充物:")) {
						填充物=li.text().replace("填充物:", "").trim();
					}
					if(li.text() !=null && li.text().contains("面料:")) {
						面料=li.text().replace("面料:", "").trim();
					}
					if(li.text() !=null && li.text().contains("风格:")) {
						风格=li.text().replace("风格:", "").trim();
					}
					if(li.text() !=null && li.text().contains("是否可拆洗:")) {
						是否可拆洗=li.text().replace("是否可拆洗:", "").trim();
					}
					if(li.text() !=null && li.text().contains("附加功能:")) {
						附加功能=li.text().replace("附加功能:", "").trim();
					}
					if(li.text() !=null && li.text().contains("是否带储物空间:")) {
						是否带储物空间=li.text().replace("是否带储物空间:", "").trim();
					}
					if(li.text() !=null && li.text().contains("产地:")) {
						产地=li.text().replace("产地:", "").trim();
					}
					if(li.text() !=null && li.text().contains("地市:")) {
						地市=li.text().replace("地市:", "").trim();
					}
					if(li.text() !=null && li.text().contains("区县:")) {
						区县=li.text().replace("区县:", "").trim();
					}
					if(li.text() !=null && li.text()!=null) {
						商品属性=商品属性+li.text().replace(",", "")+" FFFFFFF ";
					}
					
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		
		Elements lis = datadoc.getElementsByClass("tb-img").select("li");
		for (Element li : lis) {
			try {
				System.out.println("============店铺商品详细==========");
				System.out.println(li);
				Element a = li.selectFirst("a");
				String realurl = "";
				String prdName = li.attr("title");
				String datavalue = li.attr("data-value");
				Map<String, String> detailInfo = new HashMap<String, String>();
				detailInfo.put("price", "0");
				detailInfo.put("hdPrice", "0");
				detailInfo.put("startTime", "");
				detailInfo.put("endTime", "");
				detailInfo.put("type", "");

				if (propertyPics == null || propertyPics.size() == 0 || datavalue == null || "".equals(datavalue)) {
					// 页面获取图片
					String aurl = "";
					try {
						if (a != null) {
							aurl = a.attr("style");
							if ("".equals(aurl)) {
								a = datadoc.getElementById("J_UlThumb").selectFirst("li").selectFirst("a")
										.selectFirst("img");
								aurl = a.attr("src");
							}
							int last = aurl.indexOf(".jpg_");
							if (last == -1) {
								last = aurl.indexOf(".png_");
								if (last == -1) {
									last = aurl.indexOf(".jpg");
									if (last == -1) {
										last = aurl.indexOf(".png");
									}
								}
							}
							realurl = "http:" + aurl.substring(aurl.indexOf("//img."), last + 4);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

				} else {
					// 获取默认图片
					for (Object key : propertyPics.keySet()) {
						String keyString = (String) key;
						if (keyString.contains(datavalue)) {
							String tepurl = (String) ((List) propertyPics.get(keyString)).get(0);
							if (tepurl == null || "".equals(tepurl)) {
								try {
									a = datadoc.getElementById("J_UlThumb").selectFirst("li").selectFirst("a")
											.selectFirst("img");
									if (a != null) {
										String aurl = a.attr("src");
										if (aurl != null && !"".equals(aurl)) {
											int last = aurl.indexOf(".jpg_");
											if (last == -1) {
												last = aurl.indexOf(".png_");
												if (last == -1) {
													last = aurl.indexOf(".jpg");
													if (last == -1) {
														last = aurl.indexOf(".png");
													}
												}
											}
											tepurl = aurl.substring(aurl.indexOf("//img."), last + 4);
										}
									}
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
							realurl = "http:" + tepurl;
						}
					}
				}
				// 获取原价
				try {
					for (Object key : skuMap.keySet()) {
						String keyString = (String) key;
						if (keyString.contains(datavalue)) {
							String price = (String) ((Map) skuMap.get(keyString)).get("price");
							detailInfo.put("price", price);
							continue;
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				// 获取活动价格
				String skuId = "";
				try {

					for (Object key : skuListMap.keySet()) {
						String keyString = (String) key;
						if (keyString.contains(datavalue)) {
							skuId = (String) ((Map) skuListMap.get(keyString)).get("skuId");
							continue;
						}
					}
					if (skuId != null && !"".equals(skuId)) {
						Map item = (Map) priceInfo.get(skuId);
						String price = (String) item.get("price");
						detailInfo.put("price", price);
						try {
							if (item.get("suggestivePromotionList") != null) {
								List suggestivePromotionList = (List) item.get("suggestivePromotionList");
								if (suggestivePromotionList != null && suggestivePromotionList.size() > 0) {
									Map hdItem = (Map) suggestivePromotionList.get(0);
									String hdPrice = (String) hdItem.get("price");
									detailInfo.put("hdPrice", hdPrice);

									if (hdItem.get("type") != null) {
										detailInfo.put("type", (String) hdItem.get("type"));
									}
								}
							}
						} catch (Exception e) {
							e.printStackTrace();
						}
						try {
							if (item.get("promotionList") != null) {
								List promotionList = (List) item.get("promotionList");
								if (promotionList != null && promotionList.size() > 0) {
									Map hdItem = (Map) promotionList.get(0);
									String hdPrice = (String) hdItem.get("price");
									detailInfo.put("hdPrice2", hdPrice);
									if (hdItem.get("type") != null) {
										detailInfo.put("type2", (String) hdItem.get("type"));
									}
								}
							}
						} catch (Exception e) {
							e.printStackTrace();
						}
						
						try {
							if (item.get("wrtInfo") != null) {
								Map wrtInfo = (Map) item.get("wrtInfo");
								if (wrtInfo != null ) {
									Double hdPrice = Double.valueOf(wrtInfo.get("price")+"") ;
									Double finalPayment = Double.valueOf(wrtInfo.get("finalPayment")+"");
									detailInfo.put("hdPrice3", (hdPrice+finalPayment)/100 +"");
								}
							}
						} catch (Exception e) {
							e.printStackTrace();
						}

					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				if ("0".equals(detailInfo.get("hdPrice"))) {
					detailInfo.put("hdPrice", detailInfo.get("price"));
				}
				String realpath = "";
				try {
					realpath = titleString.replace("/", "-").replace("\\", "-") + "&&"
							+ prdName.replace("/", "-").replace("\\", "-") + "&&" + detailInfo.get("hdPrice") + "￥&&"
							+ chengjiao + "&&" + pingjia + "&&" + realurl.substring(realurl.lastIndexOf("/") + 1);
					realpath = replceErrorPath(realpath);
					realpath = path + replceErrorPath(titleString) + "/" + realpath;
					System.out.println("realpath:" + realpath);
					System.out.println("realurl:" + realurl);
					if((boolean) cahceMap.get("checkxqt")) {
						DownloadUtils.download(realurl, realpath);
					}
					
				} catch (Exception e) {
					e.printStackTrace();
				}
				count++;
				String detailurl = "";
				try {
					if (dianpu) {
						detailurl = url;
					} else {
						detailurl = url.substring(0, url.indexOf("&skuId=")) + "&skuId=" + skuId;
					}

				} catch (Exception e) {
					e.printStackTrace();
				}
				sb.append(titleString).append(",").append(prdName).append(",").append(detailInfo.get("price"))
						.append(",").append(chengjiao).append(",").append(pingjia).append(",").append(realpath)
						.append(",").append(realurl).append(",").append(url).append(",")
						.append(detailInfo.get("hdPrice")).append(",").append(detailInfo.get("type")).append(",")
						.append(detailInfo.get("hdPrice2")).append(",").append(detailInfo.get("type2")).append(",")
						.append(detailurl).append(",")
						.append(dianpuming).append(",")
						.append(型号).append(",")
						.append(填充物).append(",")
						.append(面料).append(",")
						.append(风格).append(",")
						.append(是否可拆洗).append(",")
						.append(附加功能).append(",")
						.append(是否带储物空间).append(",")
						.append(产地).append(",")
						.append(地市).append(",")
						.append(区县).append(",")
						.append(商品属性).append(",")
						.append(页面主推价格).append(",")
						.append(页面主推图片).append(",")
						.append(detailInfo.get("hdPrice3")).append(",")
						.append("\n");
				textArea.append("程序正在执行中下载第" + count + "张图片" + "\n");
			} catch (Exception e) {
				e.printStackTrace();
			}

		}
	}

	public static String dateFormat(Date date) {
		return new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
	}

}
